const {
    Mysql
} = require('../tools/utils');
module.exports = async ctx => {
    let {
        uid,
        vid
    } = ctx.query;
    if (uid !== 'undefined' && vid !== 'undefined') {
        let sql = `SELECT * FROM buyVideo WHERE vid =${vid} AND uid =${uid}`;
        try {
            let res = await Mysql(sql);
            if (res.length) {
                let time = String(Date.now()).split('').reverse().join('');
                let start = time.slice(0, 6);
                let end = time.slice(6, 13);
                ctx.state.data = start + '1' + end;
            }
        } catch (error) {
            let time = String(Date.now()).split('').reverse().join('');
            let start = time.slice(0, 6);
            let end = time.slice(6, 13);
            ctx.state.data = start + '0' + end;
        }
    }
}